<?php

namespace App\Http\Middleware;

use Closure;

class Account
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        /*if(str_contains( $request->getRequestUri(),'member'))
        {
            $userGroup =Group::where('name','=','users')->orWhere('name','=','admin')->get();
            $ugrops=array();
            foreach ($userGroup as $ug){
                $ugrops[] = array_fetch($ug->group_roles->toArray(),'id');
            }
            $this->roles = array_dot($ugrops);
            $useri = User::find(Auth::user()->id);
            $userRoles = array_fetch($useri->roles->toArray(),'id');
            $result = array_first($userRoles, function($key,$value){
                if(in_array($value,$this->roles))
                    return $value;
            });
            if(empty($result))
            {
                abort(404);
            }
        }*/
        return $next($request);
    }
}
